<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
    

        <script>
            $(function()
            {
                var k1 = function(){};
                         k1.prototype={

                            myajax: function(url,fn){

var xdr = new XMLHttpRequest();
xdr.onreadystatechange=function()
{
if(xdr.readyState==4)
{
    if(xdr.status>=200 && xdr.status<300 || xdr.status==304)
    {
        fn(xdr.responseText);
    }
    else{
        alert("错误文件")
    }
}
}
xdr.open("get",url,true);
xdr.send();
} 


                         }
           
          //对象实例化
              kk = new k1();
              kk.myajax("/chapter12/data/wangyi.json",function(o)
              {
                  var json = JSON.parse(o);
                  console.log(json)
              })  
            })
           
        </script>

</body>
</html>